const mongoose = require("mongoose");
const baseModel = require("./base-model");
const md5 = require("../util/md5");

console.log(1);
const userSchema = new mongoose.Schema({
  username: {
    type: String,
    required: true,
  },
  email: {
    type: String,
    required: true,
  },
  password: {
    type: String,
    required: true,
    //进行格式控制
    set: (value) => md5(value),
    //查询得时候不会查询出来
    select: false,
  },
  creatAt: {
    type: Date,
    default: Date.now,
  },
  ...baseModel,
});

module.exports = userSchema;
